//
//  MyDetailViewController.m
//  LineMoney
//
//  Created by 尹宁 on 16/7/18.
//  Copyright © 2016年 范琦. All rights reserved.
//

#import "MyDetailViewController.h"
#import "MyDetailTableViewCell.h"
#import "ChangePasswordViewController.h"
#import "ChangeAddressViewController.h"
@interface MyDetailViewController ()<UITableViewDelegate, UITableViewDataSource>

@property (nonatomic, strong) UITableView *tableView;
@end

@implementation MyDetailViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.title = @"修改资料";
    [self creatTableView];
}

- (void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    self.navigationController.navigationBarHidden = NO;
    self.tabBarController.tabBar.hidden = YES;
    
}

- (void)creatTableView
{
    self.tableView = [[UITableView alloc]initWithFrame:CGRectMake(0, -20, KSCREENWIDTH, KSCREENHEIGHT) style:UITableViewStyleGrouped];
    _tableView.delegate = self;
    _tableView.dataSource = self;
    [_tableView registerNib:[UINib nibWithNibName:@"MyDetailTableViewCell" bundle:nil] forCellReuseIdentifier:@"cell"];
    [self.view addSubview:_tableView];
    _tableView.sectionFooterHeight = 0;
    
}


#pragma mark - TableView代理方法
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 5;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 44;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    MyDetailTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
    cell.leftLabel.textColor = [UIColor colorWithRed:51 / 255.0 green:52 / 255.0 blue:51 / 255.0 alpha:1];
    cell.rightLabel.textColor = [UIColor colorWithRed:102 / 255.0 green:102 / 255.0 blue:102 / 255.0 alpha:1];
    [cell setSelectionStyle:UITableViewCellSelectionStyleNone];

    if (indexPath.row == 0) {
        cell.leftLabel.text = @"姓名";
    } else if (indexPath.row == 1) {
        cell.leftLabel.text = @"邮箱";
        cell.rightLabel.text = @"29694585@qq.com";
    } else if (indexPath.row == 2) {
        cell.leftLabel.text = @"手机号";
        cell.rightLabel.text = @"13856251456";
    } else if (indexPath.row == 3) {
        cell.leftLabel.text = @"地址";
        cell.rightLabel.hidden = YES;
    } else {
        cell.leftLabel.text = @"修改密码";
        cell.rightLabel.hidden = YES;
    }
    return cell;
    
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (indexPath.row == 3) {
        ChangeAddressViewController *change = [[ChangeAddressViewController alloc] init];
        [self.navigationController pushViewController:change animated:YES];
    }
    if (indexPath.row == 4) {
        ChangePasswordViewController *change = [[ChangePasswordViewController alloc] init];
        [self.navigationController pushViewController:change animated:YES];
    }
    
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
